package localwrap

import (
	"github.com/RocksonZeta/logger"
	"github.com/RocksonZeta/wrap/utils/fileutil"
)

var Config config

type config struct {
	DevMode bool
	Grpc    struct {
		Listen string
	}
	Ws struct {
		Listen string
	}
	Http struct {
		Listen string
	}
	Mysql string
	Redis string
	Log   struct {
		Wrap    logger.Options
		Service logger.Options
	}
	Dao struct {
		CacheTtl int
	}
	Session struct {
		Password string
		Ttl      int
	}
	Upload struct {
		ProtoIconDir string
	}
}

// var ConfigDir = fileutil.FindFileDir("config.yml")

func init() {
	err := fileutil.LoadYaml("config.yml", &Config)
	if err != nil {
		panic(err)
	}
	GetLogger().Info().Interface("config", Config).Send()
	if Config.Dao.CacheTtl <= 0 {
		Config.Dao.CacheTtl = 3600
	}
}
